#pragma once

#include "../Math/Vec2i.h"
#include "../Math/Vec3f.h";
#include <libtcod\libtcod.hpp>
#include <memory>
#include <string>

class Sun
{
public:
	Sun(const Vec2i &rise_pos, const Vec2i &set_pos, int radius = 820, int day_cycle = 3600*24);
	~Sun();

	void update(float dt);

	const Vec2i &getPos() const { return pos; }
	const Vec3f &getPos3f() const { return pos3f; }
	int getRadius() const { return radius;  }
	int getDayCycle() const { return day_cycle; }
	bool isDay() const { return day; }
	bool isNight() const { return !day; }
	float getHour() const { return hour; }
	float getCoef() const { return coef; }
	const TCODColor &getAmbient() const { return ambient; }
	const TCODColor &getColor() const { return color; }

	std::string getHourDescription() const;

private:
	void updateAmbient();
	Vec2i rise_pos; 
	Vec2i set_pos;
	Vec2i pos;
	Vec3f pos3f;
	int radius;
	int day_cycle;
	bool day;
	float hour;
	float coef;
	bool sun_climbing;
	TCODColor ambient_dawn, ambient_noon, ambient_dusk, ambient_day, ambient_night;
	TCODColor ambient, color;
};
typedef std::shared_ptr<Sun> SunPtr;

class Weather
{
public:
	Weather();
	~Weather();

	void update(float dt);

	const SunPtr &getSun() const { return sun; }

private:
	SunPtr sun;
};
typedef std::shared_ptr<Weather> WeatherPtr;
